<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">文章详情</block>
		</cu-custom>
		<view class="padding-sm bg-white solid-bottom">
			<rich-text :nodes="detail.content_a"></rich-text>			
		</view>
<!-- 		<view class="text-gray text-sm padding-sm bg-white">
			<text class="icon-attentionfill margin-lr-xs"></text>{{ detail.reading_volume }}
			<text class="icon-appreciatefill margin-lr-xs"></text> {{ detail.fabulous_value }}
			<text class="icon-messagefill margin-lr-xs"></text> {{ list.length }}
		</view> -->
		<view class="cu-list menu-avatar comment solid-top">
			<view class="cu-item" v-for="(item, index) in list" :key="index">
				<view class="cu-avatar round" :style="{backgroundImage:'url('+item.weixin_headimgurl+')'}"></view>
				<view class="content">
					<view class="text-grey">{{ item.weixin_name }}</view>
					<view class="text-gray text-content text-df">{{ item.comment }}</view>
					<view class="bg-grey padding-sm radius margin-top-sm  text-sm" v-for="(k, m) in item.review_content" :key="m">
						<view class="flex">
							<view>{{ k.weixin_name }}回复{{ k.uid_name }}:</view>
							<view class="flex-sub">{{ item.comment }}</view>
						</view>
					</view>
					<view class="margin-top-sm flex justify-between">
						<view class="text-gray text-df">{{ item.createtime }}</view>
						<view>
							<text class="icon-appreciatefill text-red"></text>
							<text class="icon-messagefill text-gray margin-left-sm"></text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { ReadMe, VideoComment } from '@/common/api/shop'
	export default {
		name: 'ReadMe',
		data () {
			return {
				params: {
					type: 1,
					appid: this.$appid,
					pid: ''
				},
				comment: {
					data_type: 2, //1视频，2文章,
					pages: 1,
					comment_id: '',
					appid: this.$appid
				},
				detail: {},
				list: []
			}
		},
		onLoad(options) {
			this.params.pid = options.id
			this.getList()
		},
		methods: {
			async getList () {
				uni.showLoading()
				await this.getDetail()
				await this.getComment()
				uni.hideLoading()
			},
			getDetail () {
				return new Promise(resolve => {
					ReadMe(this.params).then(res => {
						if (!res.code) {
							this.detail = res.data
							resolve()
						}
					})					
				})
			},
			getComment () {
				this.comment.comment_id = this.params.pid
				return new Promise(resolve => {
					VideoComment(this.comment).then(res => {
						if (!res.cdoe) {
							this.list = res.data
							resolve()
						}
					})
				})
			}
		}
	}
</script>

<style>
</style>
